package com.zs.service.impl;

import com.google.gson.Gson;
import com.zs.common.config.ResponseCode;
import com.zs.mapper.MessageMapper;
import com.zs.model.WorkLogEntity;
import com.zs.model.ResponseCodeEntity;
import com.zs.model.criteria.BaseCriteria;
import com.zs.service.MessageService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by zxw on 2017/7/4.
 */
@Service("messageService")
public class MessageServiceImpl implements MessageService {

    @Resource
    private MessageMapper messageMapper;
    @Resource
    private Gson gson;

    @Override
    public String selectMessageList(BaseCriteria baseCriteria) {
        List<WorkLogEntity> messageList = messageMapper.selectMessageList(baseCriteria);
        int recordCnt = messageMapper.selectMessageListCnt(baseCriteria);

        return gson.toJson(new ResponseCodeEntity(ResponseCode.DATA_OK,ResponseCode.DATA_SUCESS,messageList,recordCnt,baseCriteria.getPageSize(),baseCriteria.getPageNo()));
    }

	@Override
	public Integer saveMessage(WorkLogEntity workLogTo) {
		return messageMapper.saveMessage(workLogTo);
	}
}
